from rest_framework.serializers import ModelSerializer
from course.models import *
from user.models import User


class TagModelSerializer(ModelSerializer):
    class Meta:
        model = Tag
        fields = '__all__'


class SectionModelSerializer(ModelSerializer):
    class Meta:
        model = Section
        fields = '__all__'


class ChapterModelSerializer(ModelSerializer):
    section_set = SectionModelSerializer(many=True)

    class Meta:
        model = Chapter
        fields = '__all__'


class CourseModelSerializer(ModelSerializer):
    chapter_set = ChapterModelSerializer(many=True)

    class Meta:
        model = Course
        depth = 1
        fields = '__all__'


class FollowModelSerializer(ModelSerializer):
    class Meta:
        model = Follow
        fields = '__all__'


class UserModelSerializer(ModelSerializer):
    class Meta:
        model = User
        fields = ['id', 'nick_name', 'img']


class ToCourseCommentModelSerializer(ModelSerializer):
    user = UserModelSerializer()

    class Meta:
        model = CourseComment
        depth = 1
        # fields = '__all__'
        exclude = ['course']


class CourseCommentModelSerializer(ModelSerializer):
    user = UserModelSerializer()
    to = ToCourseCommentModelSerializer()

    class Meta:
        model = CourseComment
        depth = 2
        # fields = '__all__'
        exclude = ['course']
